package com.example.android_demo_2;

import com.android.volley.toolbox.ImageLoader.ImageCache;

import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

public class LruBitmapCache extends LruCache<String, Bitmap> implements
		ImageCache {

	public static int getDafaultLruCacheSize() {
		final int maxMemory = (int) (Runtime.getRuntime().maxMemory());
		final int cacheSize = maxMemory / 8;
		return cacheSize;
	}

	public LruBitmapCache() {
		this(getDafaultLruCacheSize());
	}

	public LruBitmapCache(int maxSizeKiloBytes) {
		super(maxSizeKiloBytes);
	}

	@Override
	public Bitmap getBitmap(String url) {
		return get(url);
	}

	@Override
	public void putBitmap(String url, Bitmap bitmap) {
		put(url, bitmap);
	}

}
